package com.mo.security.controller;

import com.mo.security.common.Result;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 使用自定义类实现，参考文档实现
 */
@RestController
@RequestMapping("custom-auth")
public class CustomAuthTestController {

    @GetMapping("t1")
    @PreAuthorize("@customAuthService.hasPermission()")
    public Result t1() {
        return Result.success("访问成功", null);
    }

    @GetMapping("t2")
    @PreAuthorize("@customAuthService.hasRole()")
    public Result t2() {
        return Result.success("访问成功", null);
    }
}
